
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title></title>
<%@ include file="/WEB-INF/views/include/easyui.jsp"%>
</head>
<body style="font-family: '微软雅黑'">
<div id="tb" style="padding:5px;height:auto">
    <div>
    	<form id="searchFrom" action="">
       	        <input type="text" name="name" class="easyui-validatebox" data-options="width:180,prompt: '发送人'"/>
       	        <input type="text" name="keyword" class="easyui-validatebox" data-options="width:180,prompt: '消息关键字'"/>
		        <span class="toolbar-item dialog-tool-separator"></span>
		        <a href="javascript(0)" class="easyui-linkbutton" iconCls="icon-search" plain="true" onclick="cx()">查询</a>
		</form>
    	<shiro:hasPermission name="lcs:bmsg:add">
    	<a href="#" class="easyui-linkbutton" plain="true" iconCls="icon-add" onclick="add();">新建推送</a>
    	<span class="toolbar-item dialog-tool-separator"></span>
    	</shiro:hasPermission>
    </div>
</div>
<table id="dg"></table>
 
<div id="dlg"></div> 
<div id="icon_dlg"></div>  

<script type="text/javascript">
var dg;
var d;
var permissionDg;
var parentPermId;
$(function(){   
	dg=$('#dg').datagrid({  
	method: "get",
    url:'${ctx}/messagepush/json', 
    fit : true,
	fitColumns : true,
	border : false,
	striped:true,
	idField : 'id',
	pagination:true,
	rownumbers:true,
	pageNumber:1,
	pageSize : 20,
	pageList : [ 10, 20, 30, 40, 50 ],
	singleSelect:true,
	queryParams:{
		sort: 'id', 
		order: 'asc'
		},
//	striped:true,
    columns:[[    
        {field:'id',title:'id',hidden:true,width:100,align:'center'},  
        {field:'sendUid',title:'发送人',width:50,align:'center'},
		{field:'content',title:'消息内容',width:370,align:'left'},               
        {field:'sendtime',title:'推送时间',width:80,align:'center',formatter:function(value,rowData,rowIndex){
			return formatTime(value);
		}},

    ]],
    enableHeaderClickMenu: false,
    enableHeaderContextMenu: false,
    enableRowContextMenu: false,
    toolbar:'#tb',
	});
	
});

//创建查询对象并查询
function cx(){
	var obj=$("#searchFrom").serializeObject();
	obj.keyword = encodeURIComponent(obj.keyword);
	dg.datagrid('reload',obj); 
}


//弹窗增加
function add() {
	//父级权限
	var row = dg.treegrid('getSelected');
	if(row){
		parentPermId=row.id;
	}
	
	d=$('#dlg').dialog({    
	    title: '新建推送',    
	    width: 580,    
	    height: 340,    
	    closed: false,    
	    cache: false,
	    maximizable:true,
	    resizable:true,
	    href:'${ctx}/messagepush/create',
	    modal: true,
	    buttons:[{
			text:'发送',
			handler:function(){
				if(document.getElementById('sendToAll').checked)
					var msg = "确认给所有用户推送消息？";
				else
					var msg = "确认给手机号为"+document.getElementById('telephone').value+"的用户推送消息？";
				parent.$.messager.confirm('提示', msg, function(data){
					if (data){
						$("#mainform").submit();
					} 
				});
				
			}
		},{
			text:'取消',
			handler:function(){
					d.panel('close');
				}
		}]
	});
}

var nowIcon;
var icon_dlg;
</script>
</body>
</html>